package com.bsoft.wx.controller;

import cn.hutool.core.date.DateUtil;
import com.bsoft.wx.config.shiro.JwtUtil;
import com.bsoft.wx.service.TbCheckinService;
import com.bsoft.wx.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hdh
 * @ Data   :Created in 20:55 2023/2/14
 * @ Description 签到模块接口
 * @ Modified By: hdh
 * @ Version : 1.0
 */
@RequestMapping("/checkin")
@RestController
@Api("签到web接口")
@Slf4j
public class CheckinController {
    @Autowired
    private JwtUtil jwtUtil;

    @Autowired
    private TbCheckinService tbCheckinService;

    @GetMapping("/validCanCheckIn")
    @ApiOperation("查看用户今日是否可以签到")
    public R validCanCheckIn(@RequestHeader("token") String token) {
        int userId = jwtUtil.getUserId(token);
        log.info("时间" + DateUtil.today());
        String result = tbCheckinService.validCanCheckIn(userId, DateUtil.today());
        return R.ok(result);


    }

}
